package com.hz.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hz.web.entity.PunishmentEntity;
import com.hz.web.service.IpunishmentService;

/**
 * 处罚公示controller
 * @author Administrator
 *
 */
@Controller
@RequestMapping("punishment")
public class PunishmentController {

	@Resource
	private IpunishmentService punishmentService;
	
	/**
	 * 添加 处罚公示信息
	 * @param entity
	 * @return
	 */
	@RequestMapping("addPunishment")
	@ResponseBody
	public Map<String, Object> addPunishment(PunishmentEntity entity){
		Map<String, Object> resultMap =  new HashMap<String, Object>();
		int row =-1;
		try {
			row = punishmentService.addPunishment(entity);
		} catch (Exception e) {
			e.printStackTrace();
		}
		resultMap.put("row", row);	
		return resultMap;
	}
	/**
	 * 查询处罚信息
	 * @param parmsMap
	 * @return
	 */
	@RequestMapping("queryPunishment")
	@ResponseBody
	public Map<String, Object> queryPunishment(PunishmentEntity entity,
			int page, int rows){
		Map<String, Object> resultMap =  new HashMap<String, Object>();
		//根据条件查询到的集合
		List<PunishmentEntity> ls =punishmentService.queryPunishment(entity, page, rows);
		//对应的总条数
		int count = punishmentService.queryPunishmentCount(entity);
		resultMap.put("rows", ls);
		resultMap.put("total",count);
		return resultMap;
	}
}
